package com.ray.bean;

import com.ray.util.IntegerUtil;
import com.ray.util.StringUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;
import java.util.Map;

/**
 * 
 * @ClassName: AirFlowControl
 * @Description:空气流控制开关类
 * @author: 李宇航
 * @date: 2018年7月23日 上午8:54:09
 *
 */
@Getter
@Setter
@ToString 
public class AirFlowControlBean {
	private String controlSwitchId;
	private Integer flowmeteId;
	private Integer electricityMeterId;
	private Integer autoOnAndOffSwitch;
	private String mainSwitch;
	private String company;
	private String airFlowControlId;
	private Integer handOperation;

	private List<EquipmentBean> equipmentBeans;

	private List<TemporalIntervalBean> temporalIntervalBeans;

	public AirFlowControlBean() {
		super();
	}

	public AirFlowControlBean updateSelf(Map<String, String> requestParamMap) {
		this.controlSwitchId = requestParamMap.get("controlSwitchId");
		this.flowmeteId = IntegerUtil.parseInteger(requestParamMap
				.get("flowmeteId"));
		this.electricityMeterId = IntegerUtil.parseInteger(requestParamMap
				.get("electricityMeterId"));
		this.autoOnAndOffSwitch = IntegerUtil.parseInteger(requestParamMap
				.get("autoOnAndOffSwitch"));
		this.mainSwitch = (requestParamMap.get("mainSwitch")).equals("true") ? "ON"
				: "OFF";
		this.company = requestParamMap.get("loginCompany");
		this.handOperation = IntegerUtil.parseInteger(requestParamMap
				.get("handOperation"));
		return this;
	}
	public AirFlowControlBean(Map<String, String> requestParamMap) {
		this.airFlowControlId = StringUtil.getUUID();
		this.controlSwitchId = requestParamMap.get("controlSwitchId");
		this.flowmeteId = IntegerUtil.parseInteger(requestParamMap
				.get("flowmeteId"));
		this.electricityMeterId = IntegerUtil.parseInteger(requestParamMap
				.get("electricityMeterId"));
		this.autoOnAndOffSwitch = IntegerUtil.parseInteger(requestParamMap
				.get("autoOnAndOffSwitch"));
		this.mainSwitch = (requestParamMap.get("mainSwitch")).equals("true") ? "ON"
				: "OFF";
		this.company = requestParamMap.get("loginCompany");
		this.handOperation = IntegerUtil.parseInteger(requestParamMap
				.get("handOperation"));

	}
	public boolean airFlowControlIsOpen(){
		return this.mainSwitch.equals("ON");
	}
	public void toggleAirFlowControlSwitch() {
		if("ON".equals(this.mainSwitch)){
			this.mainSwitch="OFF";
		}else{
			this.mainSwitch="ON";
		}
	}
	public boolean isHandOperating(){
		return this.handOperation==1;
	}
}
